--script engine
without inline

include std/unittest.e
include std/types.e
include std/io.e
include std/math.e
include qt/core.e as qt
include qt/qtScript.e as qs

global object _ = 0

_ = qt:init()
atom engine = qs:create()

--~ set_test_verbosity(TEST_SHOW_ALL)

--probably will change the names on these functions in script.e
test_equal("5+5", 5+5, qs:evalForInteger(engine, "5+5") )
test_equal("5.7+5", "10.700", sprintf("%4.3f",{evalForReal(engine, "5.7+5")} ) )
test_equal("4.5+5.21", "9.71", evalForString(engine, "4.5+5.21") )

--automate a bunch of random tests

--~ uncaught exception at line 1
test_equal("4.5+x undeclated"
   ,"ReferenceError: x is not defined"
   , evalForString(engine, "4.5+x")  )
printf(1,"debug message expected \n",{})     


  evalQScript(engine, read_file("test.qs"))
  
atom f =  evalQScript(engine, `
___ function test(o)
      {
         return 'o=' + o;
      }
  `)

test_equal("script o= + s"
   ,"o=1"
   , evalForString(engine, "test('1')")  )
test_equal("script o= + n"
   ,"o=1"
   , evalForString(engine, "test(1.0)")  )
test_equal("script o= + n"
   ,"o=1.2"
   , evalForString(engine, "test(1.2)")  )


test_report()

--
